<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="projectList">
      <el-table-column label="年份" align="center" prop="year" />
      <el-table-column label="项目名" align="center" prop="name"/>
      <el-table-column label="描述" align="center" prop="content" />
      <el-table-column label="报名开始时间" align="center" prop="startTime" width="140">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报名截止时间" align="center" prop="endTime" width="140">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="补报开始时间" align="center" prop="reselectStart" width="140">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.reselectStart, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="补报截止时间" align="center" prop="reselectEnd" width="140">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.reselectEnd, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="项目状态" align="center" prop="status" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleSatisfactionResult(scope.row)"
                     v-hasPermi="['lxy:project:edit']">查看项目满意度</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList" />
  </div>
</template>

<script>
import { listProject } from "@/api/lxy/project";

export default {
  name: "timeFirst",
  data() {
    return {

      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 项目表格数据
      projectList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      listProject(this.queryParams).then(response => {
        this.projectList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    //query传参,使用path跳转
    //但是用该方法每个项目的路线页面为同一个，所以需要刷新才能正常显示
    handleSatisfactionResult(row) {
      this.$router.push({
        path: '/lxy/project/satisfaction',
        query: {
          projectId: row.id,
          projectName: row.name
        }
      });
    },

  }
};
</script>
